package ru.kisa_wst.HTML;

import java.util.ArrayList;

import ru.kisa_wst.parse.Link;

/**
 * 
 * @author fed
 *
 */
public class Form {
	private Link link;
	private Link action;
	private String method;
	private ArrayList<FormParams> params;
	public Form(Link link,Link action,String method){
		this.link=link;
		this.action=action;
		this.method=method;
	}
	public Link getLink() {
		return link;
	}
	public Link getAction() {
		return action;
	}
	public String getMethod() {
		return method;
	}
	
	public ArrayList<FormParams> getParams() {
		return params;
	}
	public void addParams(FormParams formParams) {
		if(params==null) params=new ArrayList<FormParams>();
		params.add(formParams);
	}
	public void removeParams(FormParams formParams) {
		if(params!=null) {
			params.remove(formParams);
		}
	}
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("<form method=\""+getMethod()+"\"");
		builder.append(" action=\""+getAction()+"\"");
		builder.append(">\n");
		for(FormParams str:params){
			builder.append(str+"\n");
		}
		builder.append("</form>");
		return builder.toString();
	}
}
